package com.sfy.service.impl;

import com.sfy.mapper.DeptMapper;
import com.sfy.pojo.Dept;
import com.sfy.service.DeptService;
import com.sfy.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service//此类的对象交给ioc容器
public class DeptServiceImpl implements DeptService {

    @Autowired//注入持久层对象
    private DeptMapper deptMapper;

    /*查询所有部门*/
    @Override
    public List<Dept> selectAllDept() {
        List<Dept> deptList = deptMapper.selectAllDept();
        return deptList;
    }

    @Override
    public void deleteDeptById(Integer id) {
        deptMapper.deleteDeptById(id);
    }

    @Override
    public void addDept(Dept dept) {
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.addDept(dept);
    }

    @Override
    public void updateDept(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.updateDept(dept);
    }
}
